package com.xk.demo.ptDuty.service.impl;

import com.xk.demo.mybatis.entity.PtDutyEntity;
import com.xk.demo.mybatis.entity.PtRoleEntity;
import com.xk.demo.mybatis.flexigrid.PadingRstType;
import com.xk.demo.mybatis.flexigrid.PagingBean;
import com.xk.demo.mybatis.ztree.ZtreeEntity;
import com.xk.demo.ptDuty.entity.PtDutySearchEntity;
import com.xk.demo.ptDuty.mapper.PtDutyDao;
import com.xk.demo.ptDuty.service.PtDutyService;
import com.xk.demo.role.entity.SearchRoleEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

/**
 * @Author:XK
 * @Date: Created in 17:20 2022/5/16
 * @Description：
 **/
@Service("PdDutyService")
public class PtDutyServiceImpl implements PtDutyService {
    @Resource
    private PtDutyDao ptDutyDao;

    @Override
    public PadingRstType<PtDutyEntity> getDutyInfoListByPage(PtDutySearchEntity search, PagingBean paging) {
        paging.deal(PtDutyEntity.class);
        PadingRstType<PtDutyEntity> padingRstType = new PadingRstType<>();
        padingRstType.setPage(paging.getPage());
        List<PtDutyEntity> list=ptDutyDao.queryDutyListByPage(search,paging);
        Integer total=ptDutyDao.queryDutyListTotal(search);
        padingRstType.setTotal(total);
        padingRstType.setRawRecords(list);
        padingRstType.putItems();
        return padingRstType;
    }

    @Override
    public List<ZtreeEntity> getDutyZtreeList() {
        List<ZtreeEntity> list=ptDutyDao.getDutyZtreeList();
        return list;
    }

    @Override
    public List<PtDutySearchEntity> listByOrgan(String ORGAN_UUID) {
        return ptDutyDao.listByOrgan(ORGAN_UUID);
    }

    @Override
    public int insertNewPt(PtDutyEntity ptDutyEntity) {
        String dutyid = UUID.randomUUID().toString(); //36
        dutyid = dutyid.replace("-",""); //32
        ptDutyEntity.setDutyid(dutyid);
        return ptDutyDao.insertNewPt(ptDutyEntity);
    }

    @Override
    public int deleteDuty(String dutyId) {
        return ptDutyDao.deleteDuty(dutyId);
    }
}
